package canvaswork;

import geomerative.*;

/**
 *
 * @author jonatanhilden
 */
class Marquee {

    private Main main;
    RShape shp;
    int beginX, beginY, xoff, yoff;
    boolean pressed;
    boolean intersects = false;

    Marquee(Main main) {
        this.main=main;

    }

    void draw() {
        shp = RShape.createRectangle(beginX, beginY, xoff, yoff);
        //shp.setFillAlpha(150);
        main.noFill();
        main.stroke(255);
        RG.shape(shp);
    }

    RGeomElem getShp() {
        return shp;
    }

    void press(int x, int y) {
        pressed = true;
        beginX = x;
        beginY = y;

    }

    void drag() {//dragging requires that the mouse is kept pressed

        if (pressed == true) {
            xoff = -(beginX - main.mouseX);
            yoff = -(beginY - main.mouseY);
        }
    }
    // Sets the press boolean to false when mouse is released

    void release() {
        pressed = false;
        xoff = 0;
        yoff = 0;
        shp = null;
    }

    public boolean hasShp() {
        if (shp != null) {
            return true;
        } else {
            return false;
        }
    }

    boolean intersection(Grob grob) {
        return shp.intersects(grob.getShape());
    }

    void update() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
